﻿using System;
using System.Linq;
using System.Activities;
using System.Activities.Statements;

namespace WorkflowConsoleApplication1
{

    class Program
    {
        static void Main(string[] args)
        {
            System.Random rEngine = new Random(10);

            Workflow1 w = new Workflow1();
            w.MNumber1 = rEngine.Next(100);
            w.MNumber2 = rEngine.Next(100);

            Console.WriteLine(w.MNumber1.ToString() + " " + w.MNumber2.ToString());

            //var result = WorkflowInvoker.Invoke(w);

            //if (result["Result"] != null)
            //{
            //    Console.WriteLine(result["Result"].ToString());
            //}

            WorkflowApplication wa = new WorkflowApplication(w);
            wa.Completed += new Action<WorkflowApplicationCompletedEventArgs>(OnWorkflowCompleted);
            wa.Run();
            
            Console.ReadLine();
        }

        public static void OnWorkflowCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            Console.WriteLine("Completion Event Message : " + e.Outputs["Result"].ToString() + Environment.NewLine);
        }
    }
}
